<template>
  <div class="model-container">
    <div class="listName">信息管理</div>

    <el-card style="margin-top: 10px">
      <div class="table-wrapper">
        <el-table v-loading="!dataOption" :stripe="true" :data="dataOption" border empty-text="暂无数据" @selection-change="changeFun">

          <el-table-column align="center" width="55" label="序号" type="index"/>

          <el-table-column align="center" prop="paramName" label="信息名称" />

          <el-table-column align="center" prop="updateTime" label="修改时间"/>

          <el-table-column align="center" label="操作" width="500px">
            <template slot-scope="scope">
              <el-button type="primary" size="mini" plain @click="edit(scope.row)">编辑</el-button>
            </template>
          </el-table-column>

        </el-table>

        <!--分页-->
        <el-pagination
          :current-page="pageNo"
          :page-sizes="[10, 20, 30]"
          :page-size="pageSize"
          :total="rowCount"
          background
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange" />
      </div>
    </el-card>

  </div>
</template>
<script>
import * as message from '../../api/message.js'

export default {
  components: {

  },
  data() {
    return {
      // 输入禁用
      disableIinput: false,

      // 列表数据
      dataOption: null,
      pageNo: 1,
      pageSize: 10,
      rowCount: null, // 总条数

      photoGallery: [],
      type: '',
      dialogState: false,
      editorData: null,
      dialogType: 1, // 1--增加  2--编辑  3--查看
      // 对话框表单数据对象
      dialogBindData: {
        videoCateGory: '',
        videoTitle: '',
        videoData: {},
        videoCover: {},
        dianzan: ''
      },
      rules: {
        catName: [{
          required: true,
          message: '请输入分类名称',
          trigger: 'blur'
        }],
        ranking: [{
          required: true,
          message: '请输入排序',
          trigger: 'blur'
        }]
      },
      // 按钮状态
      buttonState: false,
      delBtn: true,
      delIdArr: []
    }
  },
  computed: {
    // 计算属性返回对话框文本
    dialogTitle() {
      if (this.dialogType === 1) {
        return '新增视频'
      }
      if (this.dialogType === 2) {
        return '修改视频'
      } else {
        return '查看分类'
      }
    }
  },
  beforeMount() {
    // 	  this.type = this.$route.params.type // 类型
    // 	  this.editorData = this.$route.params.data // 编辑数据

    this.getList()
  },

  methods: {
    // 删除
    changeFun(data) {
      this.datavalID = data
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.pageNo = val
      this.getList()
    },
    handleClose() {
      for (const key in this.dialogBindData) {
        if (key === 'sellerType') {
          this.dialogBindData[key] = 1
        } else if (key === 'settlementPeriod') {
          this.dialogBindData[key] = 1
        } else {
          this.dialogBindData[key] = ''
        }
      }
      this.dialogState = false
      this.disabled = false
      this.disableIinput = false
      // this.$refs.dialogBindData.clearValidate()
    },
    // 查询列表数据
    getList() {
      const param = {
        current: this.pageNo,
        size: this.pageSize
      }
      message.getMessage(param).then(res => {
        if (res.data.code !== 1) {
          this.$message.error(res.data.msg)
          return false
        }
        if (res.data.data === 'null' || res.data.data === null) {
          return false
        }
        // 初始话表格数据
        this.dataOption = res.data.data.records
        // 初始化分页数据
        this.rowCount = res.data.data.total
        this.pageSize = res.data.data.size
      })
    },

    // 编辑
    edit(data) {
      this.$router.push({
        name: '/v1/editmessage',
        params: {
          type: 3,
          data: data
        }
      })
    }

  }
}
</script>
<style>

</style>
